<template>
	<el-table-column type="index" label="#" show-overflow-tooltip />

	<el-table-column prop="machine_name" :label="$t('machine.name')" show-overflow-tooltip>
		<template #default="scope">
			{{ scope.row.machine_name || '--' }}
		</template>
	</el-table-column>

	<el-table-column prop="id" :label="$t('machine.location')" show-overflow-tooltip>
		<template #default="scope">
			{{ getaddress(scope.row) }}
		</template>
	</el-table-column>

	<el-table-column prop="totalPrice" :label="$t('home.sales')" show-overflow-tooltip>
		<template #default="scope">
			{{ getmoney(scope.row) }}
		</template>
	</el-table-column>

	<el-table-column prop="coupon_used" :label="$t('marketing.preferential.coupons')" show-overflow-tooltip>
		<template #default="scope">
			{{ scope.row.coupon_used || '0' }}
		</template>
	</el-table-column>


</template>
<script lang="ts" setup>
import { useI18n } from 'vue-i18n'
const { t: $t } = useI18n()

// 设备位置
let getaddress = (e) => {
	let address = '--'
	if (e.id == '') {
		return address
	}

	let countrys = e.country == undefined ? '' : e.country.cname || ''
	let state = e.city == undefined ? '' : e.city.cname || ''
	let citys = e.regions == undefined ? '' : e.regions.cname || ''
	let regions = e.state == undefined ? '' : e.state.cname || ''

	if (e.country != undefined) {
		if (e.country.name != null) {
			countrys += '(' + e.country.name + ')'
		}
	}

	if (e.city != undefined) {
		if (e.city.name != null) {
			state += '(' + e.city.name + ')'
		}
	}

	if (e.regions != undefined) {
		if (e.regions.name != null) {
			citys += '(' + e.regions.name + ')'
		}
	}

	if (e.state != undefined) {
		if (e.state.name != null) {
			regions += '(' + e.state.name + ')'
		}
	}

	address = countrys + '' + regions + '' + state + '' + citys

	return address || '--'

}

// 销售额
let getmoney = (e) => {
	let money = '0.00'
	if (e.id == '') {
		return money
	}

	money = (e.totalPrice * 1).toFixed(2)

	return money || '0.00'
}

</script>